<template>
  <div class="home">
    <div class="test">
      {{ $t('language.name') }}
    </div>
    <a-button type="primary"
              @click="change">
      Primary
    </a-button>
  </div>
</template>

<script>
// @ is an alias to /src
export default {
  name: 'home',
  data () {
    return {
      theme: 'light'
    }
  },
  methods: {
    change () {
      this.theme = this.theme === 'light' ? 'dark' : 'light'
      this.$initTheme(this.theme)
      this.$i18n.locale == 'zh'
        ? (this.$i18n.locale = 'en')
        : (this.$i18n.locale = 'zh') //设置中英文模式
      sessionStorage.languageSet = this.$i18n.locale //将用户设置存储到localStorage以便用户下次打开时使用此设置
    }
  }
}
</script>
<style lang="less" scoped>
.home {
  .test {
    color: var(--text-2);
  }
}
</style>
